Repository navigation
DEV-1337: don't write the clock to a streaming Shimmer3R - #339
Merged
Merged
Conversation
On a Shimmer3R the counter that stamps each streamed packet is the real-world clock, so a clock write (SET_RWC) while it streams steps that counter. Packets come out off the sample grid and sometimes behind the one before, and a step back beyond the timestamp unwrap's reorder window reads as a counter wrap, stamping the rest of the session 512 s late (DEV-1245, firmware, still in v1.1.22). startSDLogging() wrote the clock before every logging start, so starting logging mid-stream triggered it every time. The IO thread now drops a clock write unsent while a Shimmer3R streams, whatever queued it: startSDLogging(), an app's writeRealTimeClock(), or the status rule. Checking at send time also catches a write queued just before streaming started. The connect sequence still writes the clock, and the status rule writes it at the next reply while the unit isn't streaming if it is ever unset. A Shimmer3 keeps its timestamps in order across a clock write, so it still gets it mid-stream. The C# API already writes the clock only at connect, and pyshimmer and the web SDK don't write it when logging starts. API_00035 runs the IO thread over an in-memory radio. Without the fix, a streaming Shimmer3R is sent SET_RWC by startSDLogging() and by writeRealTimeClock(); with it, neither is, while an idle Shimmer3R, a streaming Shimmer3 and the connect-time write are unchanged. On a Shimmer3R over BLE (Android HIL midStreamSet and inStream, two runs each), driver 0.11.11 failed 3 of 4 with backward timestamps and 512 s jumps; this build passed 4 of 4, sending the clock once at connect and dropping the 3-4 mid-stream writes per run. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Move the check out of the IO thread: writeRealTimeClock() now queues nothing for a Shimmer3R that is streaming, and processNextInstruction() is back as it is on master. Every clock write goes through writeRealTimeClock(): the status rule, startSDLogging(), and Android's Shimmer.java. API_00027, API_00030 and API_00032 put a SET command in flight with startSDLogging() on a streaming Shimmer3R, which queued SET_RWC_COMMAND first. They now use the START_LOGGING_ONLY_COMMAND it queues alone, with GET_VBATT_COMMAND queued behind it where a test checks the next command survives. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This was referenced Oct 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
DEV-1337. The driver no longer writes the clock (
SET_RWC) to a Shimmer3R that is streaming. That removes the trigger for DEV-1245 from the Java and Android APIs: a Shimmer3R firmware issue, still in v1.1.22, where streamed timestamps go out of order and are sometimes shifted 512 s.The problem
On a Shimmer3R the counter that stamps each streamed packet is the real-world clock. Writing the clock while the unit streams steps that counter:
startSDLogging()wrote the clock before everySTART_LOGGING_ONLY_COMMAND. So any Java or Android app that started SD logging while a Shimmer3R streamed triggered it every time. The Android HIL'smidStreamSetandinStreamdo that, and they were the only failures in the 24 Oct Android release gate.The change
writeRealTimeClock()queues nothing while a Shimmer3R streams (isRealTimeClockWriteBlocked()), and logs that it didn't. Every clock write goes through it:startSDLogging(), an app's own call, and the status rule. The IO thread is unchanged.startSDLogging()betweenstartStreaming()and its ACK.writeRealTimeClock()andstartSDLogging(), and the Java HIL README's DEV-1245 note, are updated.Other APIs
None of the others writes the clock mid-stream, so this brings Java and Android into line with them:
ShimmerLogAndStream, when not logging);start_logging()and the web SDK's logging start don't write it.Android's Classic
Shimmer(with its own copy of the status rule) andShimmer3BLEAndroidboth write the clock throughwriteRealTimeClock(), so Android picks this up with the next driver release and a pin bump. At that bump,AAPI_00002,AAPI_00003andAAPI_00005need the same change as the three tests below, because they expectstartSDLogging()to queueSET_RWCon a streaming Shimmer3R.Tested
Unit test:
API_00035_NoClockWriteWhileStreamingTestruns the real IO thread over an in-memory radio and records what reaches the unit.startSDLogging()on a streaming Shimmer3RSET_RWCsentSTART_LOGGING_ONLYwriteRealTimeClock()on a streaming Shimmer3RSET_RWCsentstartSDLogging()on an idle Shimmer3RSET_RWC, thenSTART_LOGGING_ONLYstartSDLogging()on a streaming Shimmer3SET_RWCsent firstSET_RWCqueuedSET_RWCThree existing tests changed:
API_00027,API_00030andAPI_00032put a SET command in flight by callingstartSDLogging()on a streaming Shimmer3R. That used to queueSET_RWCfirst. They now use theSTART_LOGGING_ONLYit queues alone. Where a test checks that the next command survives,GET_VBATTis queued behind it.ShimmerDriverPC (103 tests) and ShimmerDriver pass.
Hardware: s3r-2f31 (Shimmer3R, LogAndStream v1.1.22) over BLE, from an M2101K6G phone on Android 11, through the Android HIL. This branch's driver was published locally as
0.11.12-dev1337; master's is 0.11.11_beta. Each scenario ran twice per driver.These runs used this branch's first commit, which dropped the clock write in the IO thread. Both scenarios call
startSDLogging()once the unit has streamed for 3 s, so a check where the write is queued blocks the same writes.midStreamSetinStreamSET_RWCper runinStreamonly reports, not fails, near an SD start🤖 Generated with Claude Code